package problems.knapsack;

public abstract class KnapsackCreator {
	public static final int H = 100;

	protected int _capacity;

	protected int _n;

	protected int _h;

	protected int[] _weights;

	protected double[] _profits;

	protected int _R;

	protected KnapsackCreator(int n, int R) {
		_n = n;
		_R = R;

		_weights = new int[n];
		_profits = new double[n];

		setInstanceNumber(1);
	}

	public void setInstanceNumber(int h) {
		_h = h;
		calcCapacity();
	}

	protected void calcCapacity() {
		_capacity = 0;
		for (int i = 0; i < _weights.length; i++) {
			_capacity += _weights[i];
		}
		_capacity = (int) (_capacity * (_h / (double) (H + 1)));
	}
	
	public int getWeight(int index) {
		return _weights[index];
	}
	
	public double getProfit(int index) {
		return _profits[index];
	}

	protected abstract void createWeightsAndProfits(int[] weights, double[] _profits2);

	public int getNumberOfItems() {
		return _n;
	}

	public int getCapacity() {
		return _capacity;
	}
}
